package GUI; 

import java.awt.EventQueue;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Toolkit;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;

import java.awt.Font;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.event.WindowEvent;

public class Alarm extends JFrame
{
	private JPanel contentPane;
	private Image img;

	public static void main(String[] args)
	{
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					Alarm frame = new Alarm();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	public Alarm()
	{
		setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
		setBounds(100, 100, 840, 640);
		this.contentPane = new JPanel() {
			public void paintComponent(Graphics g) {
				Image image2 = new ImageIcon("alarm.png").getImage();
				g.drawImage(image2, 0, 0, this);
			}
		};
		this.contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(this.contentPane);
		this.contentPane.setLayout(null);

		JPanel panel_1 = new JPanel();
		panel_1.setOpaque(false);
		panel_1.setBounds(216, 164, 450, 321);
		this.contentPane.add(panel_1);
		panel_1.setLayout(null);

		JLabel lblCurrentTime = new DigitalClock();                     //show current time use label
		lblCurrentTime.setFont(new Font("Arial Black", Font.PLAIN, 50));
		lblCurrentTime.setBounds(99, 204, 276, 142);
		panel_1.add(lblCurrentTime);

		JLabel lblNextMeeting = new JLabel(" ");
		lblNextMeeting.setBounds(141, 296, 200, 50);
		panel_1.add(lblNextMeeting);

		JButton btnConfirm = new JButton("Confirm") {                  //to close frame and move return to ealrier page
			public void paintComponent(Graphics g) {
				Image image = new ImageIcon("iconconfirm.png").getImage();
				g.drawImage(image, 0, 0, this);
			}
		};
		btnConfirm.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				close();
			}
		});
		btnConfirm.setBorder(null);
		btnConfirm.setBounds(325, 508, 220, 40);
		this.contentPane.add(btnConfirm);
	}
	
	public void close(){
	      
	       WindowEvent winClosingEvent = new WindowEvent(this,WindowEvent.WINDOW_CLOSING);
	       Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(winClosingEvent);
	   }
}